<?php
/* SVN FILE: $Id: item.php 247 2009-10-22 15:31:39Z supersmashbrothers $ */
/**
* ibMarket 2
* IP.Board 3.0
* Public Item Ajax
*
* @author $Author: supersmashbrothers $
* @copyright $Copyright$
* @version $Revision: 247 $
* @lastrevision $Date: 2009-10-22 15:31:39 +0000 (Thu, 22 Oct 2009) $
* @modifiedby $LastChangedBy: supersmashbrothers $
* @lastmodified $LastChangedDate: 2009-10-22 15:31:39 +0000 (Thu, 22 Oct 2009) $
* @filesource $URL: http://ipb-ibmarket.googlecode.com/svn/ibmarket2/trunk/admin/applications_addon/other/ibmarket/modules_public/ajax/item.php $
*/


if ( ! defined( 'IN_IPB' ) )
{
	print "<h1>Incorrect access</h1>You cannot access this file directly. If you have recently upgraded, make sure you upgraded all the relevant files.";
	exit();
}

class public_ibmarket_ajax_item extends ipsAjaxCommand
{
	/**
	* Main class entry point
	*
	* @access	public
	* @param	object		ipsRegistry reference
	* @return	void		[Outputs to screen]
	*/
	public function doExecute( ipsRegistry $registry )
	{
		if($this->memberData['member_id'] == 0 || !$this->memberData['g_market_use'])
		{
			$this->returnJsonError( 'no_permission' );
		}
		
		$inventoryItems = marketRegistry::getInventoryItem($this->memberData['member_id']);
		
		if(!is_array($inventoryItems[$this->request['item']]))
		{
			$this->returnJsonError( 'no_permission' );
		}
		
		marketRegistry::getItem($this->caches['market_items'][$inventoryItems[$this->request['item']]['item']])->publicAjax($inventoryItems[$this->request['item']]);
		
		$this->returnJsonError( 'cannot_find_item' );
	}
}